]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Add busy property to ShellApp
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Tue, 16 Sep 2014 10:08:19 +0000 (11:08 +0100)
committerPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 27 Nov 2014 10:59:55 +0000 (10:59 +0000)
Using a separate property to show when the application is busy rather
than cramming it into the state property makes the code clearer. In most
places we only care if an app is running or not, not whether it is
actually busy.

https://bugzilla.gnome.org/show_bug.cgi?id=736492

js/ui/panel.js
src/shell-app-system.c
src/shell-app.c
src/shell-app.h

index 006eb37055efb823270a09f045649220ab74e93e..dae33b8952f7e3b8d55e0785d5d4d03245b15836 100644 (file)
@@ -181,6 +181,7 @@ const AppMenuButton = new Lang.Class({
         this._targetApp = null;
         this._appMenuNotifyId = 0;
         this._actionGroupNotifyId = 0;
+        this._busyNotifyId = 0;
 
         let bin = new St.Bin({ name: 'appMenu' });
         bin.connect('style-changed', Lang.bind(this, this._onStyleChanged));
@@ -457,12 +458,17 @@ const AppMenuButton = new Lang.Class({
                 this._targetApp.disconnect(this._actionGroupNotifyId);
                 this._actionGroupNotifyId = 0;
             }
+            if (this._busyNotifyId) {
+                this._targetApp.disconnect(this._busyNotifyId);
+                this._busyNotifyId = 0;
+            }
 
             this._targetApp = targetApp;
 
             if (this._targetApp) {
                 this._appMenuNotifyId = this._targetApp.connect('notify::menu', Lang.bind(this, this._sync));
                 this._actionGroupNotifyId = this._targetApp.connect('notify::action-group', Lang.bind(this, this._sync));
+                this._busyNotifyId = this._targetApp.connect('notify::busy', Lang.bind(this, this._sync));
                 this._label.setText(this._targetApp.get_name());
                 this.actor.set_accessible_name(this._targetApp.get_name());
             }
@@ -476,7 +482,7 @@ const AppMenuButton = new Lang.Class({
 
         let isBusy = (this._targetApp != null &&
                       (this._targetApp.get_state() == Shell.AppState.STARTING ||
-                       this._targetApp.get_state() == Shell.AppState.BUSY));
+                       this._targetApp.get_busy()));
         if (isBusy)
             this.startAnimation();
         else
index d330975cd35469e3c2924f102d8280924bb52486..ff838f9794b53aed67536782246d2152fca8e4db 100644 (file)
@@ -335,7 +335,6 @@ _shell_app_system_notify_app_state_changed (ShellAppSystem *self,
   switch (state)
     {
     case SHELL_APP_STATE_RUNNING:
-    case SHELL_APP_STATE_BUSY:
       g_hash_table_insert (self->priv->running_apps, g_object_ref (app), NULL);
       break;
     case SHELL_APP_STATE_STARTING:
index 2e126218623f569bc14c7977e9e24f54ad90b9d1..a16ef5c8f3a20d859703e6d6b9efda35b2e594a9 100644 (file)
@@ -92,6 +92,7 @@ struct _ShellApp
 enum {
   PROP_0,
   PROP_STATE,
+  PROP_BUSY,
   PROP_ID,
   PROP_DBUS_ID,
   PROP_ACTION_GROUP,
@@ -123,6 +124,9 @@ shell_app_get_property (GObject    *gobject,
     case PROP_STATE:
       g_value_set_enum (value, app->state);
       break;
+    case PROP_BUSY:
+      g_value_set_boolean (value, shell_app_get_busy (app));
+      break;
     case PROP_ID:
       g_value_set_string (value, shell_app_get_id (app));
       break;
@@ -678,7 +682,6 @@ shell_app_activate_full (ShellApp      *app,
       case SHELL_APP_STATE_STARTING:
         break;
       case SHELL_APP_STATE_RUNNING:
-      case SHELL_APP_STATE_BUSY:
         shell_app_activate_window (app, NULL, timestamp);
         break;
     }
@@ -1060,22 +1063,27 @@ shell_app_on_ws_switch (MetaScreen         *screen,
   g_signal_emit (app, shell_app_signals[WINDOWS_CHANGED], 0);
 }
 
+gboolean
+shell_app_get_busy (ShellApp *app)
+{
+  if (app->running_state != NULL &&
+      app->running_state->application_proxy != NULL &&
+      shell_org_gtk_application_get_busy (app->running_state->application_proxy))
+    return TRUE;
+
+  return FALSE;
+}
+
 static void
 busy_changed_cb (GObject    *object,
                  GParamSpec *pspec,
                  gpointer    user_data)
 {
-  ShellOrgGtkApplication *proxy;
   ShellApp *app = user_data;
 
-  g_assert (SHELL_IS_ORG_GTK_APPLICATION (object));
   g_assert (SHELL_IS_APP (app));
 
-  proxy = SHELL_ORG_GTK_APPLICATION (object);
-  if (shell_org_gtk_application_get_busy (proxy))
-    shell_app_state_transition (app, SHELL_APP_STATE_BUSY);
-  else
-    shell_app_state_transition (app, SHELL_APP_STATE_RUNNING);
+  g_object_notify (G_OBJECT (app), "busy");
 }
 
 static void
@@ -1097,7 +1105,7 @@ get_application_proxy (GObject      *source,
                         G_CALLBACK (busy_changed_cb),
                         app);
       if (shell_org_gtk_application_get_busy (proxy))
-        shell_app_state_transition (app, SHELL_APP_STATE_BUSY);
+        g_object_notify (G_OBJECT (app), "busy");
     }
 
   if (app->running_state != NULL)
@@ -1577,6 +1585,19 @@ shell_app_class_init(ShellAppClass *klass)
                                                       SHELL_APP_STATE_STOPPED,
                                                       G_PARAM_READABLE));
 
+  /**
+   * ShellApp:busy:
+   *
+   * Whether the application has marked itself as busy.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_BUSY,
+                                   g_param_spec_boolean ("busy",
+                                                         "Busy",
+                                                         "Busy state",
+                                                         FALSE,
+                                                         G_PARAM_READABLE));
+
   /**
    * ShellApp:id:
    *
index 4cf7572867885aecfb0e64dd771d63aa82fffd66..2916331cb298e4cede24de79356286a52139b8d2 100644 (file)
@@ -30,8 +30,7 @@ struct _ShellAppClass
 typedef enum {
   SHELL_APP_STATE_STOPPED,
   SHELL_APP_STATE_STARTING,
-  SHELL_APP_STATE_RUNNING,
-  SHELL_APP_STATE_BUSY
+  SHELL_APP_STATE_RUNNING
 } ShellAppState;
 
 GType shell_app_get_type (void) G_GNUC_CONST;
@@ -87,6 +86,8 @@ int shell_app_compare (ShellApp *app, ShellApp *other);
 void shell_app_update_window_actions (ShellApp *app, MetaWindow *window);
 void shell_app_update_app_menu       (ShellApp *app, MetaWindow *window);
 
+gboolean shell_app_get_busy          (ShellApp *app);
+
 G_END_DECLS
 
 #endif /* __SHELL_APP_H__ */